package com.shihua.pojie;


import android.os.Environment;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Iterator;

import cn.droidlover.xdroidmvp.kit.NLog;

public class S {
    private static int[] a = {117, 32, 45, 60, 69, 79, 70, 107};

    private static int[] b = {35, 125, 97, 76, 61, 64, 104};

    private static int[] c = {68, 54, 50, 69, 80, 58};

    private static int[] d = {43, 90, 67};

    private static int[] f = {48, 33, 112, 109, 60, 19};

    private static int[] g;

    public static int copy(int[] paramArrayOfInt, int paramInt) {
        int i = paramArrayOfInt.length;
        System.arraycopy(paramArrayOfInt, 0, g, paramInt, paramArrayOfInt.length);
        return i;
    }

    public static void g() {
        if (g == null) {
            g = new int[30];
            int i = 0;
            Iterator iterator = getList().iterator();
            while (iterator.hasNext())
                i += copy((int[]) iterator.next(), i);
        }
    }

    public static ArrayList<int[]> getList() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(a);
        arrayList.add(b);
        arrayList.add(c);
        arrayList.add(d);
        arrayList.add(f);
        return arrayList;
    }

    public static void main(String[] paramArrayOfString) {
        g();
    }

    public static void sign() {
        g();
        String x = "123cscads3cjdshfasdasfnksdljnf";
        char[] temp = x.toCharArray();
        int[] result = new int[temp.length];
        for (int i = 0; i < temp.length; i++) {
            result[i] = temp[i];
        }
        StringBuilder stringBuilder = new StringBuilder();

        byte[] arrayOfByte = new byte[result.length];

        for (int i = 0; i < result.length; i++) {
            NLog.d("sign", result[i] + "=" + Integer.toBinaryString(result[i]));

            String g_k = Integer.toBinaryString(g[i]);
            String r_k = Integer.toBinaryString(result[i]);
            NLog.d("sign", "g_k==" + g_k);
            NLog.d("sign", "r_k==" + r_k);
            byte ss = (byte) (result[i] ^ g[i]);
            arrayOfByte[i] = ss;


            String rr = Integer.toBinaryString(ss);
            String towFrom = "00000000";
            towFrom = towFrom.substring(0, 8 - rr.length());
            rr = towFrom + rr;
            NLog.d("sign", rr + "==" + rr);
            stringBuilder.append(rr);
        }

        try {
            String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "sign.csr";
            File file = new File(path);
            file.createNewFile();
            FileOutputStream fileOutputStream = new FileOutputStream(path);
            fileOutputStream.write(arrayOfByte);
            fileOutputStream.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
